﻿using System.Linq;
using Foundation;
using Foundation.Sugar;
using Protocol;
using Protocol.Data;
using Protocol.Transport;

namespace Telegraph.ViewModels
{
    public class MainViewModel : ViewModel
    {
        public MainViewModel()
        {
            var channel = new LiteMessageChannel();
            channel.Connect("95.142.192.65", 443);
            var keyStoreViewModel = Store.OfType<KeyStoreViewModel>();
            keyStoreViewModel.Authorize(channel);

            Store.Snapshot();
            Register(channel);
        }

        private void Register(DataChannel channel)
        {
            var t = new DeveloperInfo
            {
                //VkId = 11838288,
                Age = 24,
                City = "Minsk",
                Mail = "poemmuse@gmail.com",
                Name = "Vladimir",
                PhoneNumber = "+375297293131"
            }; 
            
            t.Send(channel);

            var q = channel.Receive();

            //t.Send(channel);
            //q = channel.Receive();


            q = q;
        }
    }
}
